import java.sql.*;

public class JdbcUtiles {
    public  static Connection getCon() throws SQLException {
        String driver = "com.mysql.jdbc.Driver";
        String URL = "jdbc:mysql://localhost:3306/jdbc";
        String user = "root";
        String pd = "root";
        Connection con = DriverManager.getConnection(URL, user, pd);
        return  con;

    }
    public  static void close(Connection con , PreparedStatement ps , ResultSet res ){
        if (con != null) {
            try {
                con.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                con=null;
            }
        }
        if (res!=null) {
            try {
                res.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                res=null;
            }
        }
        if (ps!=null) {
            try {
                ps.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                ps=null;
            }
        }
    }

}
